Paragraph explaining casting conventions via macro
authorBastian Ilsø <bastianilso@src.gnome.org>
Tue, 27 Jan 2015 19:25:40 +0000 (19:25 +0000)
committerBastian Ilsø <bastianilso@src.gnome.org>
Tue, 27 Jan 2015 21:40:19 +0000 (21:40 +0000)
docs/reference/gtk/getting_started.xml

index 63d79cdc95caff8b127b281b95da26ac9278be38..892425b3292800c4580091a0e3eece4c39f41eb8 100644 (file)
     by the windowing system: it will have a frame, a title bar and window
     controls, depending on the platform.</para>
 
+    <para>A window title is set using gtk_window_set_title(). This function
+    takes a GtkWindow* pointer and a string as input. As our 
+    <varname>window</varname> pointer is a GtkWidget pointer, we need to cast it
+    to GtkWindow*.
+    But instead of casting <varname>window</varname> via 
+    <varname>(GtkWindow*)</varname>, 
+    <varname>window</varname> can be cast using the macro 
+    <varname>GTK_WINDOW()</varname>.
+    <varname>GTK_WINDOW()</varname> will check if the 
+    pointer is an instance of the GtkWindow class, before casting, and emit a
+    warning if the check fails. More information about this convention 
+    can be found 
+    <ulink url="https://developer.gnome.org/gobject/stable/gtype-conventions.html">
+    here</ulink>.</para>
+
     <para>In order to terminate the application when the #GtkWindow is
     destroyed, we connect the #GtkWidget::destroy signal to the gtk_main_quit()
     function. This function will terminate the GTK+ main loop started by calling